package com.lin.generate.config;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import com.lin.generate.common.enums.SystemConst;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;

/**
 * @Author: z156940l@outlook.com
 * @Date: 2021/8/2 15:04
 */
@Component
public class MyMetaObjectHandler implements MetaObjectHandler  {

    @Override
    public void insertFill(MetaObject metaObject) {
        this.setFieldValByName("createTime", LocalDateTime.now(), metaObject);
        this.setFieldValByName("updateTime", LocalDateTime.now(), metaObject);
        this.setFieldValByName("status", SystemConst.NOT_DELETE.getMsg(), metaObject);

    }

    @Override
    public void updateFill(MetaObject metaObject) {
        this.setFieldValByName("updateTime", LocalDateTime.now(), metaObject);

    }
}
